home *** CD-ROM | disk | FTP | other *** search
- Path: abcfd20.larc.nasa.gov!amiga-request
- From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
- Subject: v90i250: DKBTrace 2.01 - DKBtrace Ray-Tracer, Part02/10
- Reply-To: David Schanen <mtv@milton.u.washington.edu>
- Newsgroups: comp.sources.amiga
- Message-ID: <comp.sources.amiga:v90i250@abcfd20.larc.nasa.gov>
- References: <comp.sources.amiga:v90i249@abcfd20.larc.nasa.gov>
- Date: 03 Sep 90 23:21:37 GMT
- Approved: tadguy@uunet.UU.NET (Tad Guy)
- X-Mail-Submissions-To: amiga@uunet.uu.net
- X-Post-Discussions-To: comp.sys.amiga
-
- Submitted-by: David Schanen <mtv@milton.u.washington.edu>
- Posting-number: Volume 90, Issue 250
- Archive-name: applications/dkbtrace-2.01/part02
-
- #!/bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 2 (of 10)."
- # Contents: Docs/12to20.doc Docs/BasicShapes.data Docs/unixmakefile
- # src/Dump2RGB.c src/gio.c src/ilbmw.c src/makefile src/palette.c
- # src/prioq.c src/raw.c src/showprioq.c
- # Wrapped by tadguy@abcfd20 on Mon Sep 3 19:21:16 1990
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'Docs/12to20.doc' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Docs/12to20.doc'\"
- else
- echo shar: Extracting \"'Docs/12to20.doc'\" \(6186 characters\)
- sed "s/^X//" >'Docs/12to20.doc' <<'END_OF_FILE'
- XData file conversion from DKB 1.2 to 2.0 guidelines:
- X
- XThe only MANDATORY conversion(s) will be to data files that contain CSG
- X"DIFFERENCE" types. The previous format required you to list the primary
- Xobject last, with the previous entries "subtracted" from the last object.
- XThe new format requires the primary object to be specified first, then
- Xthe other shapes to be subtracted follow. This is more intuitive, and more
- Xlike a subtraction equation. Subtractions performed by "INVERT" 'ing various
- Xobjects rather than specifically by the "DIFFERENCE" function are O.K. as is.
- X
- XThe Old Way:
- X
- XOBJECT
- X DIFFERENCE
- X subtracted shape 1
- X subtracted shape 2
- X subtracted shape 3
- X subtracted shape 4
- X orignal starting shape
- X END_DIFFERENCE
- X.
- X.
- XEND_OBJECT
- X
- X
- XThe New Way:
- X
- XOBJECT
- X DIFFERENCE
- X orignal starting shape
- X subtracted shape 1
- X subtracted shape 2
- X subtracted shape 3
- X subtracted shape 4
- X END_DIFFERENCE
- X.
- X.
- XEND_OBJECT
- X
- X
- XOther changes not required, but HIGHLY recommended (for speed), are to replace
- Xthe slower general QUADRIC types with the new primitive types SPHERE and
- XPLANE, when possible.
- X
- X
- X
- XSPHERES:
- X
- XA "Sphere" QUADRIC is effectively "built" around the origin with a default
- Xsize (radius) of 1.0. SCALE functions will become the sphere's radius, while
- XTRANSLATE functions will become the sphere's new "origin" or center.
- X
- XNOTE: This will only work for symmetrically scaled spheres (where all 3 SCALE
- X values are the same). For oblate sphereoids, you will still need to
- X use the general QUADRIC type. SPHERES cannot be "stretched" properly.
- X
- XThe simplest conversion is:
- X
- XOld: QUADRIC "Sphere" SCALE <10.0 10.0 10.0> END_QUADRIC
- X
- XNew: SPHERE <0.0 0.0 0.0> 10.0 END_SPHERE
- X
- XThis will then generate a true sphere at the origin (<0.0 0.0 0.0>), and of
- Xthe size indicated (10). Any previous TRANSLATE or ROTATE (or even SCALE)
- Xcommands will still work properly. To not change any of the SCALE statements,
- Xetc. you should specify a radius of 1.0, then all object transformations will
- Xoccur exactly as they did previously.
- X
- XAnother conversion you can make is to include any TRANSLATE statements into
- Xthe "center" statement of the sphere.
- X
- XOld: QUADRIC "Sphere" TRANSLATE <3.0 10.0 5.0> END_QUADRIC
- X
- XNew: SPHERE <3.0 10.0 5.0> 1.0 END_SPHERE
- X
- XThis will then generate a true sphere at the origin indicated, with the
- Xdefault radius of 1.0. Any further previous TRANSLATE or ROTATE (or even
- XSCALE) commands will work as expected.
- X
- X
- X
- XPLANES:
- X
- XA "Plane_xx" QUADRIC is effectively "built" at the origin, but extends in
- Xany two of three dimensions (Plane_XY, Plane_XZ, etc). You must determine
- Xthe plane's orientation: for easy figuring, the dimension NOT specified in
- Xthe old name of the plane is the direction of the "UP" vector for the new
- XPLANE primitive. Translate values may be changed into the "how far up is UP"
- Xvalue for the PLANE primitive.
- X
- X(For example, in an "Plane_XZ", the "Y" axis is the unspecifed axis)
- X
- XOld: QUADRIC "Plane_XZ" TRANSLATE <0.0 -5.0 0.0> END_QUADRIC
- X
- XSo, the "Y" axis becomes the "UP" vector, and the TRANSLATE gives us the "how
- Xfar up is UP" parameter:
- X
- XNew: PLANE <0.0 1.0 0.0> -5.0 END_PLANE
- X | |
- X "UP" direction -- -- "How far up is UP?"
- X on the Y axis
- X
- XThis will then generate a true plane in the direction(s) indicated, and trans-
- Xlate it up (or down, in this example) along the "UP" vector. Any previous
- XTRANSLATE or ROTATE (or even SCALE) commands will work properly. To not
- Xchange any of the TRANSLATE, etc. statements, the "how far up" parameter
- Xshould be 0.0 (make the plane on the "origin" of <0.0 0.0 0.0>), then any
- Xtransformations will work as before.
- X
- XNOTE: PLANES, like their QUADRIC counterparts, extend out to infinity. If
- X you desire a "clipped" plane (one of finite size) it is easiest to
- X define two TRIANGLE primitives, laid so their hypotenuse(s) are back
- X to back.
- X
- X
- X
- XLIGHT SOURCES:
- X
- XOne important thing to remember when defining a LIGHT_SOURCE is this: The
- Xcenter of the light source MUST be "TRANSLATED" to wherever you want the point
- Xsource to be. Simply specifying the "origin" of the sphere to be there DOES
- XNOT WORK, although it seems as though is should. Light sources being
- Xconverted to SPHERE types from QUADRIC types should be defined about the
- X<0.0 0.0 0.0> origin, with the appropriate radius taken from any SCALE
- Xstatements, but MUST then be "TRANSLATE" 'ed to wherever you want the light
- Xto be. Chances are, due to the fact that QUADRIC "Spheres" are generated
- Xcentered about the <0.0 0.0 0.0> origin, there will already be the proper
- X"TRANSLATE" statement there in the object's definition.
- X
- XOld:
- X
- XOBJECT
- X QUADRIC "Sphere" SCALE <2.0 2.0 2.0> END_QUADRIC
- X TRANSLATE <0.0 200.0 0.0>
- X LIGHT_SOURCE
- X .
- X .
- XEND_OBJECT
- X
- XNew:
- X
- XOBJECT
- X SPHERE <0.0 0.0 0.0> 2.0 END_SPHERE
- X TRANSLATE <0.0 200.0 0.0>
- X LIGHT_SOURCE
- X .
- X .
- XEND_OBJECT
- X
- X
- X
- XIMAGE QUALITY
- X
- XA new added feature for speed of tracing is the Quality parameter:
- X
- XQ1 = Basic object positions only, nothing but Ambient Light illumination.
- XQ3 = All of the above, plus Diffuse Lighting of objects.
- XQ5 = All of the above, plus Shadows from Light Sources and Highlights.
- XQ7 = All of the above, plus Textures.
- XQ9 = All of the above, plus Reflection, Refraction, and Transmittance.
- X
- XThe values in-between are reserved for future expansion. Using a lower
- Xquality value is great for quick renderings just to see where the heck the
- Xvarious objects you have defined wind up.
- X
- XOne important thing to note about Quality: If you have a textured object in
- Xyour scene, you probably didn't give the basic object a COLOUR. If you plan
- Xon rendering it with the "Quality" factor less than 7, you _MUST_ declare a
- XCOLOUR for the object in addition to the texture, if it is to be visible.
- XThis is so the ambient or diffuse light has some colour on the object to hit
- Xwhile the surface texture is turned off. When you finally render with Quality
- Xof 7 or greater, the defined basic object colour will not be seen, but rather
- Xyour intended texture.
- X
- X
- X
- XNot too horrible, eh? - Enjoy the plethora of new features and increased
- XSPEED of DKB 2.0 !
- END_OF_FILE
- if test 6186 -ne `wc -c <'Docs/12to20.doc'`; then
- echo shar: \"'Docs/12to20.doc'\" unpacked with wrong size!
- fi
- # end of 'Docs/12to20.doc'
- fi
- if test -f 'Docs/BasicShapes.data' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Docs/BasicShapes.data'\"
- else
- echo shar: Extracting \"'Docs/BasicShapes.data'\" \(4415 characters\)
- sed "s/^X//" >'Docs/BasicShapes.data' <<'END_OF_FILE'
- XDECLARE Sphere = QUADRIC
- X <1.0 1.0 1.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X -1.0
- XEND_QUADRIC
- X
- XDECLARE Cylinder_X = QUADRIC
- X <0.0 1.0 1.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X -1.0
- XEND_QUADRIC
- X
- XDECLARE Cylinder_Y = QUADRIC
- X <1.0 0.0 1.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X -1.0
- XEND_QUADRIC
- X
- XDECLARE Cylinder_Z = QUADRIC
- X <1.0 1.0 0.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X -1.0
- XEND_QUADRIC
- X
- XDECLARE Cone_X = QUADRIC
- X <0.0 1.0 1.0>
- X <0.0 0.0 0.0>
- X <1.0 0.0 0.0>
- X 0.0
- XEND_QUADRIC
- X
- XDECLARE Cone_Y = QUADRIC
- X <1.0 0.0 1.0>
- X <0.0 0.0 0.0>
- X <0.0 1.0 0.0>
- X 0.0
- XEND_QUADRIC
- X
- XDECLARE Cone_Z = QUADRIC
- X <1.0 1.0 0.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 1.0>
- X 0.0
- XEND_QUADRIC
- X
- XDECLARE Plane_YZ = QUADRIC
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X <1.0 0.0 0.0>
- X 0.0
- XEND_QUADRIC
- X
- XDECLARE Plane_XZ = QUADRIC
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X <0.0 1.0 0.0>
- X 0.0
- XEND_QUADRIC
- X
- XDECLARE Plane_XY = QUADRIC
- X <0.0 0.0 0.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 1.0>
- X 0.0
- XEND_QUADRIC
- X
- X
- X{ y^2 + z^2 - x = 0 }
- XDECLARE Paraboloid_X = QUADRIC
- X <0.0 1.0 1.0>
- X <0.0 0.0 0.0>
- X <-1.0 0.0 0.0>
- X 0.0
- XEND_QUADRIC
- X
- X
- X{ x^2 + z^2 - y = 0 }
- XDECLARE Paraboloid_Y = QUADRIC
- X <1.0 0.0 1.0>
- X <0.0 0.0 0.0>
- X <0.0 -1.0 0.0>
- X 0.0
- XEND_QUADRIC
- X
- X
- X{ x^2 + y^2 - z = 0 }
- XDECLARE Paraboloid_Z = QUADRIC
- X <1.0 1.0 0.0>
- X <0.0 0.0 0.0>
- X <0.0 0.0 -1.0>
- X 0.0
- XEND_QUADRIC
- X
- X
- X{ y - x^2 + z^2 = 0 }
- XDECLARE Hyperboloid = QUADRIC
- X < -1.0 0.0 1.0>
- X < 0.0 0.0 0.0>
- X < 0.0 1.0 0.0>
- X 0.0
- XEND_QUADRIC
- X
- XDECLARE Black = COLOUR RED 0.0 GREEN 0.0 BLUE 0.0
- XDECLARE White = COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
- XDECLARE Red = COLOUR RED 1.0
- XDECLARE Green = COLOUR GREEN 1.0
- XDECLARE Blue = COLOUR BLUE 1.0
- XDECLARE Yellow = COLOUR RED 1.0 GREEN 1.0
- XDECLARE Cyan = COLOUR BLUE 1.0 GREEN 1.0
- XDECLARE Magenta = COLOUR RED 1.0 BLUE 1.0
- X
- XDECLARE Red_Marble = TEXTURE
- X MARBLE
- X TURBULENCE 1.0
- X COLOUR_MAP
- X [0.0 0.8 COLOUR RED 0.8 GREEN 0.8 BLUE 0.6
- X COLOUR RED 0.8 GREEN 0.4 BLUE 0.4]
- X [0.8 1.001 COLOUR RED 0.8 GREEN 0.4 BLUE 0.4
- X COLOUR RED 0.8 GREEN 0.2 BLUE 0.2]
- X END_COLOUR_MAP
- X SCALE <10.0 10.0 10.0>
- XEND_TEXTURE
- X
- XDECLARE Brown_Agate = TEXTURE
- X AGATE
- X TURBULENCE 0.3
- X COLOUR_MAP
- X [0.0 0.5 COLOUR RED 1.0 GREEN 1.0 BLUE 1.0
- X COLOUR RED 0.9 GREEN 0.7 BLUE 0.6]
- X [0.5 0.6 COLOUR RED 0.9 GREEN 0.7 BLUE 0.6
- X COLOUR RED 0.9 GREEN 0.7 BLUE 0.4]
- X [0.6 1.001 COLOUR RED 0.9 GREEN 0.7 BLUE 0.4
- X COLOUR RED 0.7 GREEN 0.4 BLUE 0.2]
- X END_COLOUR_MAP
- X SCALE <10.0 10.0 10.0>
- XEND_TEXTURE
- X
- XDECLARE Blue_Marble = TEXTURE
- X AGATE
- X TURBULENCE 0.3
- X COLOUR_MAP
- X [0.0 0.5 COLOUR RED 0.30 GREEN 0.30 BLUE 0.50
- X COLOUR RED 0.30 GREEN 0.30 BLUE 0.50]
- X [0.5 0.55 COLOUR RED 0.30 GREEN 0.30 BLUE 0.50
- X COLOUR RED 0.20 GREEN 0.20 BLUE 0.30]
- X [0.55 0.6 COLOUR RED 0.20 GREEN 0.20 BLUE 0.30
- X COLOUR RED 0.25 GREEN 0.25 BLUE 0.35]
- X [0.6 0.7 COLOUR RED 0.25 GREEN 0.25 BLUE 0.35
- X COLOUR RED 0.15 GREEN 0.15 BLUE 0.26]
- X [0.7 0.8 COLOUR RED 0.15 GREEN 0.15 BLUE 0.26
- X COLOUR RED 0.10 GREEN 0.10 BLUE 0.20]
- X [0.8 0.9 COLOUR RED 0.10 GREEN 0.10 BLUE 0.20
- X COLOUR RED 0.30 GREEN 0.30 BLUE 0.50]
- X [0.9 1.001 COLOUR RED 0.30 GREEN 0.30 BLUE 0.50
- X COLOUR RED 0.10 GREEN 0.10 BLUE 0.20]
- X END_COLOUR_MAP
- X SCALE <10.0 10.0 10.0>
- XEND_TEXTURE
- X
- XDECLARE Dull = TEXTURE
- X AMBIENT 0.3
- X DIFFUSE 0.7
- XEND_TEXTURE
- X
- XDECLARE Shiny = TEXTURE
- X AMBIENT 0.3
- X DIFFUSE 0.7
- X PHONG 1.0
- X PHONGSIZE 20.0
- XEND_TEXTURE
- X
- XDECLARE Mirror = TEXTURE
- X AMBIENT 0.0
- X DIFFUSE 0.0
- X REFLECTION 1.0
- XEND_TEXTURE
- X
- XDECLARE Luminous = TEXTURE
- X AMBIENT 1.0
- X DIFFUSE 0.0
- XEND_TEXTURE
- X
- XDECLARE Glass = TEXTURE
- X AMBIENT 0.0
- X DIFFUSE 0.0
- X REFLECTION 0.5
- X REFRACTION 0.5
- X IOR 1.2
- XEND_TEXTURE
- X
- XDECLARE Metal = TEXTURE
- X AMBIENT 0.3
- X DIFFUSE 0.7
- X BRILLIANCE 6.0
- XEND_TEXTURE
- X
- XDECLARE Glass2 = TEXTURE
- X AMBIENT 0.0
- X DIFFUSE 0.0
- X REFLECTION 0.5
- X REFRACTION 0.5
- XEND_TEXTURE
- END_OF_FILE
- if test 4415 -ne `wc -c <'Docs/BasicShapes.data'`; then
- echo shar: \"'Docs/BasicShapes.data'\" unpacked with wrong size!
- fi
- # end of 'Docs/BasicShapes.data'
- fi
- if test -f 'Docs/unixmakefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Docs/unixmakefile'\"
- else
- echo shar: Extracting \"'Docs/unixmakefile'\" \(6342 characters\)
- sed "s/^X//" >'Docs/unixmakefile' <<'END_OF_FILE'
- X# Makefile for DKB Ray Tracing Program by David Buck and Aaron Collins
- X# This file is released to the public domain.
- X#
- X#
- X# MAKE Macros and Such...
- X#
- X
- X#***************************************************************
- X#*
- X#* Amiga Options
- X#*
- X#***************************************************************
- X
- X# Uncomment for Amiga Lattice C FFP
- X#CFLAGS = -cusrft -ff -m0 -q5w5e -b0 -O -v
- X#DUMPFLAGS = -cusrt -ff -m0 -q5w5e -O -v
- X
- X# Uncomment for Amiga Lattice C with 68881
- X#CFLAGS = -cusrft -f8 -m2 -q5w5e -b0 -O -v
- X
- X# Flags for debugging
- X# CFLAGS = -cusrft -f8 -m2 -b0 -q5w5e -d5 -v
- X
- X#LIBSFFP = lib:lcmffp.lib lib:lcnb.lib lib:amiga.lib
- X#LIBS881 = lib:lcm881.lib lib:lcnb.lib lib:amiga.lib
- XOBJ = o
- XMACHINE_OBJ = unix.$(OBJ)
- XCFLAGS= -c -O
- XLFLAGS = -o dkbtrace -O
- X
- X
- X# Make's implicit rules for making a .o file from a .c file...
- X#
- X.c.o :
- X $(CC) $(CFLAGS) $*.c
- X
- X# Generic "Unix" MAKE's implicit rules for making a .OBJ file from a .C file
- X#
- X#*.o : *.c
- X# $(CC) $(CFLAGS) $*
- X
- X#***************************************************************
- X#*
- X#* IBM Options
- X#*
- X#***************************************************************
- X
- X# Note for the IBM Version:
- X# Uses system environment variable LIB for the linker's .LIB file path.
- X# (Example: Set LIB=C:\LIB) if you change this the two .LNK files will also
- X# need to be changed as well. The system environment variable CMODEL also
- X# may be defined for the memory model of the compiler. DKBTrace requires
- X# the "Large" memory model. (Example Set CMODEL=l) If you don't want to
- X# use the DOS environment variables, uncomment the following two lines:
- X
- X#CMODEL =l
- X#LIB =c:\lib
- X
- X#CC =tcc
- X#OBJ =obj
- X#MACHINE_OBJ = ibm.$(OBJ)
- X#
- X# Uncomment Turbo Link for Symbolic Debugging, or use DOS/MS-LINK for
- X# faster .EXE execution speed (shame on you, Borland, for no FARCALL!...)
- X# Note: you also must use a -v in the CFLAGS rather than -v- if you want
- X# to use the symbolic debugging facilities of Turbo-Debug.
- X
- X#TLINK =tlink /l/v
- X#TLINK =link /EXEPACK /PACKCODE /FARCALL
- X#
- X# IBM (Turbo-MAKE, actually) Specific MAKE Directives:
- X#
- X#
- X# Uncomment This for No Numeric Data Processor Extension (No Math Co)
- X#LINKFLAGS=$(LIB)\emu+$(LIB)\math$(CMODEL)+$(LIB)\c$(CMODEL);
- X#
- X# Uncomment This for NDP Extension (80x87 Co-Processor) Support
- X#LINKFLAGS=$(LIB)\fp87+$(LIB)\math$(CMODEL)+$(LIB)\c$(CMODEL);
- X#
- X
- X# Uncomment for 8086/8088 instruction set usage
- X#
- X#CFLAGS =-m$(CMODEL) -r -K -G -O -Z -d -c -v- -k- -N-
- X
- X
- X# Uncomment for 80186/80268 (incl. V20!) instruction set usage
- X#
- X#CFLAGS =-m$(CMODEL) -1 -a -r -K -G -O -Z -d -c -v- -k- -N-
- X
- X# Turbo-MAKE's implicit rules for making a .OBJ file from a .C file...
- X#
- X#.c.obj :
- X# $(CC) $(CFLAGS) $*
- X
- X# Generic "Unix" MAKE's implicit rules for making a .OBJ file from a .C file
- X#
- X#*.obj : *.c
- X# $(CC) $(CFLAGS) $*
- X
- X
- X#***************************************************************
- X#*
- X#* Common Stuff
- X#*
- X#***************************************************************
- X
- XDKBOBJS = trace.$(OBJ) render.$(OBJ) tokenize.$(OBJ) parse.$(OBJ) \
- X objects.$(OBJ) spheres.$(OBJ) quadrics.$(OBJ) lighting.$(OBJ) \
- X prioq.$(OBJ) texture.$(OBJ) matrices.$(OBJ) csg.$(OBJ) \
- X colour.$(OBJ) viewpnt.$(OBJ) ray.$(OBJ) planes.$(OBJ) iff.$(OBJ) \
- X gif.$(OBJ) gifdecod.$(OBJ) triangle.$(OBJ) raw.$(OBJ) $(MACHINE_OBJ)
- X
- X
- X# Amiga Linkage...
- X#
- X#trace881: $(DKBOBJS)
- X# blink with withfile LIB $(LIBS881) TO trace881
- X
- X#traceffp: $(DKBOBJS)
- X# blink with withfile LIB $(LIBSFFP) TO traceffp
- X
- X#Sculpt2DKB: Sculpt2DKB.o
- X# blink lib:c.o Sculpt2DKB.o lib $(LIBSFFP) to Sculpt2DKB
- X
- X# IBM Linkage...
- X#
- X#dkb.exe : $(DKBOBJS)
- X#
- X
- X#$(TLINK) @dkb.lnk
- X
- X#Sculpt2DKB.exe : Sculpt2DKB.obj
- X# $(TLINK) $(LIB)\c0$(CMODEL)+Sculpt2DKB,Sculpt2DKB,Sculpt2DKB/m,$(LINKFLAGS);
- X
- X#gluetga.exe : gluetga.obj
- X# $(TLINK) $(LIB)\c0$(CMODEL)+gluetga,gluetga,gluetga/m,$(LINKFLAGS);
- X
- X#halftga.exe : halftga.obj
- X# $(TLINK) $(LIB)\c0$(CMODEL)+halftga,halftga,halftga/m,$(LINKFLAGS);
- X
- Xdkbtrace: $(DKBOBJS)
- X cc $(LFLAGS) $(DKBOBJS) -lm
- X
- X#
- X# Specific module/header dependencies for DKBtrace:
- X#
- X
- XSculpt2DKB.$(OBJ) : Sculpt2DKB.c dkbproto.h frame.h
- X
- Xhalftga.$(OBJ) : halftga.c
- X
- Xgluetga.$(OBJ) : gluetga.c
- X
- Xtrace.$(OBJ) : trace.c dkbproto.h frame.h vector.h config.h
- X
- Xtokenize.$(OBJ) : tokenize.c dkbproto.h frame.h config.h
- X
- Xparse.$(OBJ) : parse.c dkbproto.h frame.h config.h
- X
- Xrender.$(OBJ) : render.c dkbproto.h frame.h vector.h config.h
- X
- Xlighting.$(OBJ) : lighting.c dkbproto.h frame.h vector.h config.h
- X
- Xprioq.$(OBJ) : prioq.c dkbproto.h frame.h config.h
- X
- Xtexture.$(OBJ) : texture.c dkbproto.h frame.h vector.h config.h
- X
- Xobjects.$(OBJ) : objects.c dkbproto.h frame.h vector.h config.h
- X
- Xspheres.$(OBJ) : spheres.c dkbproto.h frame.h vector.h config.h
- X
- Xplanes.$(OBJ) : planes.c dkbproto.h frame.h vector.h config.h
- X
- Xquadrics.$(OBJ) : quadrics.c dkbproto.h frame.h vector.h config.h
- X
- Xmatrices.$(OBJ) : matrices.c dkbproto.h frame.h vector.h config.h
- X
- Xcsg.$(OBJ) : csg.c dkbproto.h frame.h vector.h config.h
- X
- Xcolour.$(OBJ) : colour.c dkbproto.h frame.h config.h
- X
- Xviewpnt.$(OBJ) : viewpnt.c dkbproto.h frame.h vector.h config.h
- X
- Xray.$(OBJ) : ray.c dkbproto.h frame.h vector.h config.h
- X
- Xiff.$(OBJ) : iff.c dkbproto.h frame.h config.h
- X
- Xgif.$(OBJ) : gif.c dkbproto.h frame.h config.h
- X
- Xgifdecod.$(OBJ) : gifdecod.c dkbproto.h frame.h config.h
- X
- Xraw.$(OBJ) : raw.c dkbproto.h frame.h config.h
- X
- Xtriangle.$(OBJ) : triangle.c dkbproto.h frame.h vector.h config.h
- X
- Xamiga.$(OBJ) : amiga.c dkbproto.h frame.h config.h
- X
- Xibm.$(OBJ) : ibm.c dkbproto.h frame.h config.h
- X
- Xunix.$(OBJ) : unix.c dkbproto.h frame.h config.h
- X
- X
- X#
- X#
- X# Utilities
- X#
- X
- X# Amiga Linkage
- X#
- XDump2RGB: Dump2RGB.o
- X blink lib:c.o Dump2RGB.o LIB $(LIBSFFP) TO Dump2RGB
- X
- XDump2Raw: Dump2Raw.o
- X blink lib:c.o Dump2Raw.o LIB $(LIBSFFP) TO Dump2Raw
- X
- XDumpToIFF: DumpToIFF.o palette.o showprioq.o gio.o iffw.o ilbmw.o putpict.o packer.o
- X blink with dumpwithfile LIB $(LIBSFFP) TO DumpToIFF
- X
- XDumpToIFF.o: DumpToIFF.c
- X $(CC) $(DUMPFLAGS) $*
- X
- XDump2RGB.o: Dump2RGB.c
- X
- XDump2Raw.o: Dump2Raw.c
- X
- Xpalette.o: palette.c showprioq.h
- X $(CC) $(DUMPFLAGS) $*
- X
- Xshowprioq.o: showprioq.c showprioq.h
- X $(CC) $(DUMPFLAGS) $*
- X
- Xgio.o: gio.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xiffw.o: iffw.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xilbmw.o: ilbmw.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xputpict.o: putpict.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xpacker.o: packer.c
- X $(CC) $(DUMPFLAGS) $*
- END_OF_FILE
- if test 6342 -ne `wc -c <'Docs/unixmakefile'`; then
- echo shar: \"'Docs/unixmakefile'\" unpacked with wrong size!
- fi
- # end of 'Docs/unixmakefile'
- fi
- if test -f 'src/Dump2RGB.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/Dump2RGB.c'\"
- else
- echo shar: Extracting \"'src/Dump2RGB.c'\" \(5693 characters\)
- sed "s/^X//" >'src/Dump2RGB.c' <<'END_OF_FILE'
- X#include "frame.h"
- X
- X/* #define IBM TRUE */
- X
- X#define Amiga TRUE
- X
- XIMAGE Raw_Image;
- X
- XFILE *fp, *palette_file, *output_palette_file;
- XFILE *fred, *fgrn, *fblu;
- Xchar input_filename[100], master_filename[100], output_filename[100];
- Xint image_width, image_height;
- X
- X#ifdef IBM
- X#define REDNAME "%s.r8"
- X#define GRNNAME "%s.g8"
- X#define BLUNAME "%s.b8"
- X#define DEFAULT_WIDTH 320
- X#define DEFAULT_HEIGHT 200
- X#endif
- X
- X#ifdef Amiga
- X#define REDNAME "%s.red"
- X#define GRNNAME "%s.grn"
- X#define BLUNAME "%s.blu"
- X#define DEFAULT_WIDTH 320
- X#define DEFAULT_HEIGHT 400
- X#endif
- X
- Xint read_raw_byte PARAMS((FILE *f));
- Xint read_raw_word PARAMS((FILE *f));
- Xvoid read_raw_image PARAMS((IMAGE *Image));
- Xvoid get_parameters PARAMS((int argc, char **argv));
- Xvoid OpenRGB PARAMS((void));
- Xvoid SaveRGB PARAMS((int red, int grn, int blu));
- X
- Xvoid main (argc, argv)
- X int argc;
- X char **argv;
- X {
- X unsigned int x, y, index;
- X
- X if (argc < 2)
- X {
- X printf ("\nUsage: DumpToRGB [-wxxx -hxxx] <filename>\n .dis extension is assumed for <filename>\n default image size: %d x %d", DEFAULT_WIDTH, DEFAULT_HEIGHT);
- X exit(0);
- X }
- X
- X fp = NULL;
- X
- X get_parameters(argc, argv);
- X
- X printf ("Reading raw file\n");
- X read_raw_image (&Raw_Image);
- X
- X printf ("Converting...\n");
- X
- X OpenRGB();
- X for (y = 0 ; y < Raw_Image.height ; y++) {
- X for (x = 0 ; x < Raw_Image.width ; x++) {
- X index = y*Raw_Image.width + x;
- X SaveRGB((int)Raw_Image.red[index],(int)Raw_Image.green[index],(int)Raw_Image.blue[index]);
- X }
- X for (; x < image_width ; x++)
- X SaveRGB(0, 0, 0);
- X }
- X for (; y < image_height ; y++)
- X for (; x < image_width; x++)
- X SaveRGB(0, 0, 0);
- X fclose(fred);
- X fclose(fgrn);
- X fclose(fblu);
- X }
- X
- Xvoid get_parameters (argc, argv)
- X int argc;
- X char **argv;
- X {
- X int i, filename_number;
- X
- X image_height = DEFAULT_HEIGHT;
- X image_width = DEFAULT_WIDTH;
- X
- X filename_number = 0;
- X for (i = 1 ; i < argc ; i++) {
- X
- X if (argv[i][0] == '-')
- X switch (argv[i][1]) {
- X case 'w': sscanf(&argv[i][2], "%d", &image_height);
- X break;
- X case 'h': sscanf(&argv[i][2], "%d", &image_height);
- X break;
- X default : printf("Unknown option %s - proceeding...\n");
- X }
- X else
- X switch (filename_number) {
- X case 0: strcpy (master_filename, argv[i]);
- X sprintf (input_filename, "%s.dis", master_filename);
- X filename_number++;
- X break;
- X
- X default: printf ("Too many filenames in commandline\n");
- X exit(1);
- X }
- X }
- X }
- X
- X
- Xint read_raw_byte(f)
- X FILE *f;
- X {
- X int c;
- X if ((c = getc(f)) == EOF)
- X return (-1);
- X return (c);
- X }
- X
- Xint read_raw_word(f)
- X FILE *f;
- X {
- X int byte1, byte2;
- X
- X byte1 = read_raw_byte(f);
- X if (byte1 == -1)
- X return(-1);
- X
- X byte2 = read_raw_byte(f);
- X if (byte2 == -1)
- X return(-1);
- X
- X return (byte1 + byte2*256);
- X }
- X
- Xvoid OpenRGB()
- X{
- X char nmbuff[200];
- X
- X sprintf( nmbuff, REDNAME, master_filename );
- X if ((fred = fopen(nmbuff, "wb")) == NULL) {
- X printf ("Cannot open red output file for %s\n", master_filename);
- X exit(1);
- X }
- X
- X sprintf( nmbuff, GRNNAME, master_filename );
- X if ((fgrn = fopen(nmbuff, "wb")) == NULL) {
- X printf ("Cannot open green output file for %s\n", master_filename);
- X exit(1);
- X }
- X
- X sprintf( nmbuff, BLUNAME, master_filename );
- X if ((fblu = fopen(nmbuff, "wb")) == NULL) {
- X printf ("Cannot open blue output file for %s\n", master_filename);
- X exit(1);
- X }
- X}
- X
- Xvoid SaveRGB(red, grn, blu)
- Xint red, grn, blu;
- X{
- X fputc( red, fred );
- X fputc( grn, fgrn );
- X fputc( blu, fblu );
- X}
- X
- Xvoid read_raw_image(Image)
- X IMAGE *Image;
- X {
- X FILE *f;
- X unsigned int i, index, pixels;
- X int byte, row;
- X
- X if ((f = fopen(input_filename, "rb")) == NULL) {
- X printf ("Cannot open raw file %s\n", input_filename);
- X exit(1);
- X }
- X
- X Image->width = read_raw_word(f);
- X if (Image->width == -1) {
- X printf ("Cannot read size in dump file\n");
- X exit(1);
- X }
- X
- X Image->height = read_raw_word(f);
- X if (Image->height == -1) {
- X printf ("Cannot read size in dump file: %s\n", input_filename);
- X exit(1);
- X }
- X
- X pixels = Image->width * Image->height;
- X
- X if (((Image->red = (unsigned char *) malloc(pixels))==NULL) ||
- X ((Image->green = (unsigned char *) malloc(pixels))==NULL) ||
- X ((Image->blue = (unsigned char *) malloc(pixels))==NULL)) {
- X printf ("Cannot allocate memory for picture: %s\n", input_filename);
- X exit(1);
- X }
- X
- X for (i = 0 ; i < pixels ; i++) {
- X Image->red[i] = 0;
- X Image->green[i] = 0;
- X Image->blue[i] = 0;
- X }
- X
- X row = read_raw_word(f);
- X while (row != -1) {
- X for (i = 0 ; i < Image->width ; i++) {
- X index = row*Image->width + i;
- X
- X byte = read_raw_byte(f);
- X if (byte == -1) {
- X printf ("Unexpected end of file in raw image: %s\n", input_filename);
- X exit(1);
- X }
- X Image->red[index] = byte;
- X }
- X
- X for (i = 0 ; i < Image->width ; i++) {
- X index = row*Image->width + i;
- X
- X byte = read_raw_byte(f);
- X if (byte == -1) {
- X printf ("Unexpected end of file in raw image: %s\n", input_filename);
- X exit(1);
- X }
- X Image->green[index] = byte;
- X }
- X
- X for (i = 0 ; i < Image->width ; i++) {
- X index = row*Image->width + i;
- X
- X byte = read_raw_byte(f);
- X if (byte == -1) {
- X printf ("Unexpected end of file in raw image: %s\n", input_filename);
- X exit(1);
- X }
- X Image->blue[index] = byte;
- X }
- X row = read_raw_word(f);
- X }
- X fclose (f);
- X }
- END_OF_FILE
- if test 5693 -ne `wc -c <'src/Dump2RGB.c'`; then
- echo shar: \"'src/Dump2RGB.c'\" unpacked with wrong size!
- fi
- # end of 'src/Dump2RGB.c'
- fi
- if test -f 'src/gio.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/gio.c'\"
- else
- echo shar: Extracting \"'src/gio.c'\" \(4579 characters\)
- sed "s/^X//" >'src/gio.c' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------*/
- X/* GIO.C Generic I/O Speed Up Package 1/23/86 */
- X/* See GIOCall.C for an example of usage. */
- X/* Read not speeded-up yet. Only one Write file buffered at a time. */
- X/* Note: The speed-up provided is ONLY significant for code such as IFF */
- X/* which does numerous small Writes and Seeks. */
- X/* */
- X/* By Jerry Morrison and Steve Shaw, Electronic Arts. */
- X/* This software is in the public domain. */
- X/* */
- X/* This version for the Commodore-Amiga computer. */
- X/* */
- X/*----------------------------------------------------------------------*/
- X#include "iff/gio.h" /* See comments here for explanation.*/
- X
- X#if GIO_ACTIVE
- X
- X#define local static
- X
- X
- Xlocal BPTR wFile = NULL;
- Xlocal BYTE *wBuffer = NULL;
- Xlocal LONG wNBytes = 0; /* buffer size in bytes.*/
- Xlocal LONG wIndex = 0; /* index of next available byte.*/
- Xlocal LONG wWaterline = 0; /* Count of # bytes to be written.
- X * Different than wIndex because of GSeek.*/
- X
- X/*----------- GOpen ----------------------------------------------------*/
- XLONG GOpen(filename, openmode) char *filename; LONG openmode; {
- X return( Open(filename, openmode) );
- X }
- X
- X/*----------- GClose ---------------------------------------------------*/
- XLONG GClose(file) BPTR file; {
- X LONG signal = 0, signal2;
- X if (file == wFile)
- X signal = GWriteUndeclare(file);
- X signal2 = Close(file); /* Call Close even if trouble with write.*/
- X if (signal2 < 0)
- X signal = signal2;
- X return( signal );
- X }
- X
- X/*----------- GRead ----------------------------------------------------*/
- XLONG GRead(file, buffer, nBytes) BPTR file; BYTE *buffer; LONG nBytes; {
- X LONG signal = 0;
- X /* We don't yet read directly from the buffer, so flush it to disk and
- X * let the DOS fetch it back. */
- X if (file == wFile)
- X signal = GWriteFlush(file);
- X if (signal >= 0)
- X signal = Read(file, buffer, nBytes);
- X return( signal );
- X }
- X
- X/* ---------- GWriteFlush ----------------------------------------------*/
- XLONG GWriteFlush(file) BPTR file; {
- X LONG gWrite = 0;
- X if (wFile != NULL && wBuffer != NULL && wIndex > 0)
- X gWrite = Write(wFile, wBuffer, wWaterline);
- X wWaterline = wIndex = 0; /* No matter what, make sure this happens.*/
- X return( gWrite );
- X }
- X
- X/* ---------- GWriteDeclare --------------------------------------------*/
- XLONG GWriteDeclare(file, buffer, nBytes)
- X BPTR file; BYTE *buffer; LONG nBytes; {
- X LONG gWrite = GWriteFlush(wFile); /* Finish any existing usage.*/
- X if ( file==NULL || (file==wFile && buffer==NULL) || nBytes<=3) {
- X wFile = NULL; wBuffer = NULL; wNBytes = 0; }
- X else {
- X wFile = file; wBuffer = buffer; wNBytes = nBytes; }
- X return( gWrite );
- X }
- X
- X/* ---------- GWrite ---------------------------------------------------*/
- XLONG GWrite(file, buffer, nBytes) BPTR file; BYTE *buffer; LONG nBytes; {
- X LONG gWrite = 0;
- X
- X if (file == wFile && wBuffer != NULL) {
- X if (wNBytes >= wIndex + nBytes) {
- X /* Append to wBuffer.*/
- X movmem(buffer, wBuffer+wIndex, nBytes);
- X wIndex += nBytes;
- X if (wIndex > wWaterline)
- X wWaterline = wIndex;
- X nBytes = 0; /* Indicate data has been swallowed.*/
- X }
- X else {
- X wWaterline = wIndex; /* We are about to overwrite any
- X * data above wIndex, up to at least the buffer end.*/
- X gWrite = GWriteFlush(file); /* Write data out in proper order.*/
- X }
- X }
- X if (nBytes > 0 && gWrite >= 0)
- X gWrite += Write(file, buffer, nBytes);
- X return( gWrite );
- X }
- X
- X/* ---------- GSeek ----------------------------------------------------*/
- XLONG GSeek(file, position, mode)
- X BPTR file; LONG position; LONG mode; {
- X LONG gSeek = -2;
- X LONG newWIndex = wIndex + position;
- X
- X if (file == wFile && wBuffer != NULL) {
- X if (mode == OFFSET_CURRENT &&
- X newWIndex >= 0 && newWIndex <= wWaterline) {
- X gSeek = wIndex; /* Okay; return *OLD* position */
- X wIndex = newWIndex;
- X }
- X else {
- X /* We don't even try to optimize the other cases.*/
- X gSeek = GWriteFlush(file);
- X if (gSeek >= 0) gSeek = -2; /* OK so far */
- X }
- X }
- X if (gSeek == -2)
- X gSeek = Seek(file, position, mode);
- X return( gSeek );
- X }
- X
- X#else /* not GIO_ACTIVE */
- X
- Xvoid GIODummy() { } /* to keep the compiler happy */
- X
- X#endif GIO_ACTIVE
- END_OF_FILE
- if test 4579 -ne `wc -c <'src/gio.c'`; then
- echo shar: \"'src/gio.c'\" unpacked with wrong size!
- fi
- # end of 'src/gio.c'
- fi
- if test -f 'src/ilbmw.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/ilbmw.c'\"
- else
- echo shar: Extracting \"'src/ilbmw.c'\" \(5438 characters\)
- sed "s/^X//" >'src/ilbmw.c' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------*
- X * ILBMW.C Support routines for writing ILBM files. 1/23/86
- X * (IFF is Interchange Format File.)
- X *
- X * By Jerry Morrison and Steve Shaw, Electronic Arts.
- X * This software is in the public domain.
- X *
- X * This version for the Commodore-Amiga computer.
- X *----------------------------------------------------------------------*/
- X#include "iff/packer.h"
- X#include "iff/ilbm.h"
- X#include <graphics/view.h>
- X
- X/*---------- InitBMHdr -------------------------------------------------*/
- XIFFP InitBMHdr(bmHdr0, bitmap, masking, compression, transparentColor,
- X pageWidth, pageHeight)
- X BitMapHeader *bmHdr0; struct BitMap *bitmap;
- X WORD masking; /* Masking */
- X WORD compression; /* Compression */
- X WORD transparentColor; /* UWORD */
- X WORD pageWidth, pageHeight;
- X {
- X register BitMapHeader *bmHdr = bmHdr0;
- X register WORD rowBytes = bitmap->BytesPerRow;
- X
- X bmHdr->w = rowBytes << 3;
- X bmHdr->h = bitmap->Rows;
- X bmHdr->x = bmHdr->y = 0; /* Default position is (0,0).*/
- X bmHdr->nPlanes = bitmap->Depth;
- X bmHdr->masking = masking;
- X bmHdr->compression = compression;
- X bmHdr->pad1 = 0;
- X bmHdr->transparentColor = transparentColor;
- X bmHdr->xAspect = bmHdr->yAspect = 1;
- X bmHdr->pageWidth = pageWidth;
- X bmHdr->pageHeight = pageHeight;
- X
- X if (pageWidth < 360)
- X if (pageHeight < 250) {
- X bmHdr->xAspect = x320x200Aspect;
- X bmHdr->yAspect = y320x200Aspect;
- X }
- X else {
- X bmHdr->xAspect = x320x400Aspect;
- X bmHdr->yAspect = y320x400Aspect;
- X }
- X else
- X if (pageHeight < 250) {
- X bmHdr->xAspect = x640x200Aspect;
- X bmHdr->yAspect = y640x200Aspect;
- X }
- X else {
- X bmHdr->xAspect = x640x400Aspect;
- X bmHdr->yAspect = y640x400Aspect;
- X }
- X
- X return( IS_ODD(rowBytes) ? CLIENT_ERROR : IFF_OKAY );
- X }
- X
- X/*---------- PutCMAP ---------------------------------------------------*/
- XIFFP PutCMAP(context, vp)
- X GroupContext *context;
- X struct ViewPort *vp;
- X {
- X IFFP iffp;
- X ColorRegister colorReg;
- X int nColorRegs;
- X UWORD *CMapEntry;
- X struct ColorMap *colorMap;
- X
- X colorMap = vp->ColorMap;
- X nColorRegs = colorMap->Count;
- X
- X if ((vp->Modes & HIRES) && (nColorRegs > 16))
- X nColorRegs = 16;
- X
- X if ((vp->Modes & HAM) && (nColorRegs > 16))
- X nColorRegs = 16;
- X
- X iffp = PutCkHdr(context, ID_CMAP, nColorRegs * sizeofColorRegister);
- X CheckIFFP();
- X
- X CMapEntry = (UWORD *)colorMap->ColorTable;
- X
- X for (; nColorRegs; --nColorRegs) {
- X colorReg.red = ( *CMapEntry >> 4 ) & 0xf0;
- X colorReg.green = ( *CMapEntry ) & 0xf0;
- X colorReg.blue = ( *CMapEntry << 4 ) & 0xf0;
- X iffp = IFFWriteBytes(context, (BYTE *)&colorReg, sizeofColorRegister);
- X CheckIFFP();
- X CMapEntry++;
- X }
- X
- X iffp = PutCkEnd(context);
- X return(iffp);
- X }
- X
- XIFFP PutCAMG(context, mode)
- X GroupContext *context;
- X LONG mode;
- X {
- X IFFP iffp;
- X int CAMG_Size = 4;
- X
- X iffp = PutCkHdr(context, ID_CAMG, 4L);
- X CheckIFFP();
- X
- X iffp = IFFWriteBytes(context, (BYTE *)&mode, CAMG_Size);
- X CheckIFFP();
- X
- X iffp = PutCkEnd(context);
- X return(iffp);
- X }
- X
- X/*---------- PutBODY ---------------------------------------------------*/
- X/* NOTE: This implementation could be a LOT faster if it used more of the
- X * supplied buffer. It would make far fewer calls to IFFWriteBytes (and
- X * therefore to DOS Write). */
- XIFFP PutBODY(context, bitmap, mask, bmHdr, buffer, bufsize)
- X GroupContext *context; struct BitMap *bitmap; BYTE *mask;
- X BitMapHeader *bmHdr; BYTE *buffer; LONG bufsize;
- X {
- X IFFP iffp;
- X LONG rowBytes = bitmap->BytesPerRow;
- X int dstDepth = bmHdr->nPlanes;
- X Compression compression = bmHdr->compression;
- X int planeCnt; /* number of bit planes including mask */
- X register int iPlane, iRow;
- X register LONG packedRowBytes;
- X BYTE *buf;
- X BYTE *planes[MaxAmDepth + 1]; /* array of ptrs to planes & mask */
- X
- X if ( bufsize < MaxPackedSize(rowBytes) || /* Must buffer a comprsd row*/
- X compression > cmpByteRun1 || /* bad arg */
- X bitmap->Rows != bmHdr->h || /* inconsistent */
- X rowBytes != RowBytes(bmHdr->w) || /* inconsistent*/
- X bitmap->Depth < dstDepth || /* inconsistent */
- X dstDepth > MaxAmDepth ) /* too many for this routine*/
- X return(CLIENT_ERROR);
- X
- X planeCnt = dstDepth + (mask == NULL ? 0 : 1);
- X
- X /* Copy the ptrs to bit & mask planes into local array "planes" */
- X for (iPlane = 0; iPlane < dstDepth; iPlane++)
- X planes[iPlane] = (BYTE *)bitmap->Planes[iPlane];
- X if (mask != NULL)
- X planes[dstDepth] = mask;
- X
- X /* Write out a BODY chunk header */
- X iffp = PutCkHdr(context, ID_BODY, szNotYetKnown);
- X CheckIFFP();
- X
- X /* Write out the BODY contents */
- X for (iRow = bmHdr->h; iRow > 0; iRow--) {
- X for (iPlane = 0; iPlane < planeCnt; iPlane++) {
- X
- X /* Write next row.*/
- X if (compression == cmpNone) {
- X iffp = IFFWriteBytes(context, planes[iPlane], rowBytes);
- X planes[iPlane] += rowBytes;
- X }
- X
- X /* Compress and write next row.*/
- X else {
- X buf = buffer;
- X packedRowBytes = PackRow(&planes[iPlane], &buf, rowBytes);
- X iffp = IFFWriteBytes(context, buffer, packedRowBytes);
- X }
- X
- X CheckIFFP();
- X }
- X }
- X
- X /* Finish the chunk */
- X iffp = PutCkEnd(context);
- X return(iffp);
- X }
- END_OF_FILE
- if test 5438 -ne `wc -c <'src/ilbmw.c'`; then
- echo shar: \"'src/ilbmw.c'\" unpacked with wrong size!
- fi
- # end of 'src/ilbmw.c'
- fi
- if test -f 'src/makefile' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/makefile'\"
- else
- echo shar: Extracting \"'src/makefile'\" \(6233 characters\)
- sed "s/^X//" >'src/makefile' <<'END_OF_FILE'
- X# Makefile for DKB Ray Tracing Program by David Buck and Aaron Collins
- X# This file is released to the public domain.
- X#
- X#
- X# MAKE Macros and Such...
- X#
- X
- X#***************************************************************
- X#*
- X#* Amiga Options
- X#*
- X#***************************************************************
- X
- X# Uncomment for Amiga Lattice C FFP
- X#CFLAGS = -cusrft -ff -m0 -q5w5e -b0 -O -v
- XDUMPFLAGS = -cusrt -ff -m0 -q5w5e -O -v
- X
- X# Uncomment for Amiga Lattice C with 68881
- XCFLAGS = -cusrft -f8 -m2 -q5w5e -b0 -O -v
- X
- X# Flags for debugging
- X# CFLAGS = -cusrft -f8 -m2 -b0 -q5w5e -d5 -v
- X
- XLIBSFFP = lib:lcmffp.lib lib:lcnb.lib lib:amiga.lib
- XLIBS881 = lib:lcm881.lib lib:lcnb.lib lib:amiga.lib
- XOBJ = o
- XMACHINE_OBJ = amiga.$(OBJ)
- X
- X
- X# Make's implicit rules for making a .o file from a .c file...
- X#
- X#.c.o :
- X# $(CC) $(CFLAGS) $*
- X
- X# Generic "Unix" MAKE's implicit rules for making a .OBJ file from a .C file
- X#
- X#*.o : *.c
- X# $(CC) $(CFLAGS) $*
- X
- X#***************************************************************
- X#*
- X#* IBM Options
- X#*
- X#***************************************************************
- X
- X# Note for the IBM Version:
- X# Uses system environment variable LIB for the linker's .LIB file path.
- X# (Example: Set LIB=C:\LIB) if you change this the two .LNK files will also
- X# need to be changed as well. The system environment variable CMODEL also
- X# may be defined for the memory model of the compiler. DKBTrace requires
- X# the "Large" memory model. (Example Set CMODEL=l) If you don't want to
- X# use the DOS environment variables, uncomment the following two lines:
- X
- X#CMODEL =l
- X#LIB =c:\lib
- X
- X#CC =tcc
- X#OBJ =obj
- X#MACHINE_OBJ = ibm.$(OBJ)
- X#
- X# Uncomment Turbo Link for Symbolic Debugging, or use DOS/MS-LINK for
- X# faster .EXE execution speed (shame on you, Borland, for no FARCALL!...)
- X# Note: you also must use a -v in the CFLAGS rather than -v- if you want
- X# to use the symbolic debugging facilities of Turbo-Debug.
- X
- X#TLINK =tlink /l/v
- X#TLINK =link /EXEPACK /PACKCODE /FARCALL
- X#
- X# IBM (Turbo-MAKE, actually) Specific MAKE Directives:
- X#
- X#
- X# Uncomment This for No Numeric Data Processor Extension (No Math Co)
- X#LINKFLAGS=$(LIB)\emu+$(LIB)\math$(CMODEL)+$(LIB)\c$(CMODEL);
- X#
- X# Uncomment This for NDP Extension (80x87 Co-Processor) Support
- X#LINKFLAGS=$(LIB)\fp87+$(LIB)\math$(CMODEL)+$(LIB)\c$(CMODEL);
- X#
- X
- X# Uncomment for 8086/8088 instruction set usage
- X#
- X#CFLAGS =-m$(CMODEL) -r -K -G -O -Z -d -c -v- -k- -N-
- X
- X
- X# Uncomment for 80186/80268 (incl. V20!) instruction set usage
- X#
- X#CFLAGS =-m$(CMODEL) -1 -a -r -K -G -O -Z -d -c -v- -k- -N-
- X
- X# Turbo-MAKE's implicit rules for making a .OBJ file from a .C file...
- X#
- X#.c.obj :
- X# $(CC) $(CFLAGS) $*
- X
- X# Generic "Unix" MAKE's implicit rules for making a .OBJ file from a .C file
- X#
- X#*.obj : *.c
- X# $(CC) $(CFLAGS) $*
- X
- X
- X#***************************************************************
- X#*
- X#* Common Stuff
- X#*
- X#***************************************************************
- X
- XDKBOBJS = trace.$(OBJ) render.$(OBJ) tokenize.$(OBJ) parse.$(OBJ) \
- X objects.$(OBJ) spheres.$(OBJ) quadrics.$(OBJ) lighting.$(OBJ) \
- X prioq.$(OBJ) texture.$(OBJ) matrices.$(OBJ) csg.$(OBJ) \
- X colour.$(OBJ) viewpnt.$(OBJ) ray.$(OBJ) planes.$(OBJ) iff.$(OBJ) \
- X gif.$(OBJ) gifdecod.$(OBJ) triangle.$(OBJ) raw.$(OBJ) $(MACHINE_OBJ)
- X
- X
- X# Amiga Linkage...
- X#
- Xtrace881: $(DKBOBJS)
- X blink with withfile LIB $(LIBS881) TO trace881
- X
- Xtraceffp: $(DKBOBJS)
- X blink with withfile LIB $(LIBSFFP) TO traceffp
- X
- XSculpt2DKB: Sculpt2DKB.o
- X blink lib:c.o Sculpt2DKB.o lib $(LIBSFFP) to Sculpt2DKB
- X
- X# IBM Linkage...
- X#
- Xdkb.exe : $(DKBOBJS)
- X $(TLINK) @dkb.lnk
- X
- XSculpt2DKB.exe : Sculpt2DKB.obj
- X $(TLINK) $(LIB)\c0$(CMODEL)+Sculpt2DKB,Sculpt2DKB,Sculpt2DKB/m,$(LINKFLAGS);
- X
- Xgluetga.exe : gluetga.obj
- X $(TLINK) $(LIB)\c0$(CMODEL)+gluetga,gluetga,gluetga/m,$(LINKFLAGS);
- X
- Xhalftga.exe : halftga.obj
- X $(TLINK) $(LIB)\c0$(CMODEL)+halftga,halftga,halftga/m,$(LINKFLAGS);
- X
- X#
- X# Specific module/header dependencies for DKBtrace:
- X#
- X
- XSculpt2DKB.$(OBJ) : Sculpt2DKB.c dkbproto.h frame.h
- X
- Xhalftga.$(OBJ) : halftga.c
- X
- Xgluetga.$(OBJ) : gluetga.c
- X
- Xtrace.$(OBJ) : trace.c dkbproto.h frame.h vector.h config.h
- X
- Xtokenize.$(OBJ) : tokenize.c dkbproto.h frame.h config.h
- X
- Xparse.$(OBJ) : parse.c dkbproto.h frame.h config.h
- X
- Xrender.$(OBJ) : render.c dkbproto.h frame.h vector.h config.h
- X
- Xlighting.$(OBJ) : lighting.c dkbproto.h frame.h vector.h config.h
- X
- Xprioq.$(OBJ) : prioq.c dkbproto.h frame.h config.h
- X
- Xtexture.$(OBJ) : texture.c dkbproto.h frame.h vector.h config.h
- X
- Xobjects.$(OBJ) : objects.c dkbproto.h frame.h vector.h config.h
- X
- Xspheres.$(OBJ) : spheres.c dkbproto.h frame.h vector.h config.h
- X
- Xplanes.$(OBJ) : planes.c dkbproto.h frame.h vector.h config.h
- X
- Xquadrics.$(OBJ) : quadrics.c dkbproto.h frame.h vector.h config.h
- X
- Xmatrices.$(OBJ) : matrices.c dkbproto.h frame.h vector.h config.h
- X
- Xcsg.$(OBJ) : csg.c dkbproto.h frame.h vector.h config.h
- X
- Xcolour.$(OBJ) : colour.c dkbproto.h frame.h config.h
- X
- Xviewpnt.$(OBJ) : viewpnt.c dkbproto.h frame.h vector.h config.h
- X
- Xray.$(OBJ) : ray.c dkbproto.h frame.h vector.h config.h
- X
- Xiff.$(OBJ) : iff.c dkbproto.h frame.h config.h
- X
- Xgif.$(OBJ) : gif.c dkbproto.h frame.h config.h
- X
- Xgifdecod.$(OBJ) : gifdecod.c dkbproto.h frame.h config.h
- X
- Xraw.$(OBJ) : raw.c dkbproto.h frame.h config.h
- X
- Xtriangle.$(OBJ) : triangle.c dkbproto.h frame.h vector.h config.h
- X
- Xamiga.$(OBJ) : amiga.c dkbproto.h frame.h config.h
- X
- Xibm.$(OBJ) : ibm.c dkbproto.h frame.h config.h
- X
- Xunix.$(OBJ) : unix.c dkbproto.h frame.h config.h
- X
- X
- X#
- X#
- X# Utilities
- X#
- X
- X# Amiga Linkage
- X#
- XDump2RGB: Dump2RGB.o
- X blink lib:c.o Dump2RGB.o LIB $(LIBSFFP) TO Dump2RGB
- X
- XDump2Raw: Dump2Raw.o
- X blink lib:c.o Dump2Raw.o LIB $(LIBSFFP) TO Dump2Raw
- X
- XDumpToIFF: DumpToIFF.o palette.o showprioq.o gio.o iffw.o ilbmw.o putpict.o packer.o
- X blink with dumpwithfile LIB $(LIBSFFP) TO DumpToIFF
- X
- XDumpToIFF.o: DumpToIFF.c
- X $(CC) $(DUMPFLAGS) $*
- X
- XDump2RGB.o: Dump2RGB.c
- X
- XDump2Raw.o: Dump2Raw.c
- X
- Xpalette.o: palette.c showprioq.h
- X $(CC) $(DUMPFLAGS) $*
- X
- Xshowprioq.o: showprioq.c showprioq.h
- X $(CC) $(DUMPFLAGS) $*
- X
- Xgio.o: gio.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xiffw.o: iffw.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xilbmw.o: ilbmw.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xputpict.o: putpict.c
- X $(CC) $(DUMPFLAGS) $*
- X
- Xpacker.o: packer.c
- X $(CC) $(DUMPFLAGS) $*
- END_OF_FILE
- if test 6233 -ne `wc -c <'src/makefile'`; then
- echo shar: \"'src/makefile'\" unpacked with wrong size!
- fi
- # end of 'src/makefile'
- fi
- if test -f 'src/palette.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/palette.c'\"
- else
- echo shar: Extracting \"'src/palette.c'\" \(5971 characters\)
- sed "s/^X//" >'src/palette.c' <<'END_OF_FILE'
- X/*****************************************************************************
- X*
- X* dumproto.h
- X*
- X* from DKBTrace (c) 1990 David Buck
- X*
- X* This file contains routines to choose colour palettes for DumpToIFF
- X*
- X* This software is freely distributable. The source and/or object code may be
- X* copied or uploaded to communications services so long as this notice remains
- X* at the top of each file. If any changes are made to the program, you must
- X* clearly indicate in the documentation and in the programs startup message
- X* who it was who made the changes. The documentation should also describe what
- X* those changes were. This software may not be included in whole or in
- X* part into any commercial package without the express written consent of the
- X* author. It may, however, be included in other public domain or freely
- X* distributed software so long as the proper credit for the software is given.
- X*
- X* This software is provided as is without any guarantees or warranty. Although
- X* the author has attempted to find and correct any bugs in the software, he
- X* is not responsible for any damage caused by the use of the software. The
- X* author is under no obligation to provide service, corrections, or upgrades
- X* to this package.
- X*
- X* Despite all the legal stuff above, if you do find bugs, I would like to hear
- X* about them. Also, if you have any comments or questions, you may contact me
- X* at the following address:
- X*
- X* David Buck
- X* 22C Sonnet Cres.
- X* Nepean Ontario
- X* Canada, K2H 8W7
- X*
- X* I can also be reached on the following bulleton boards:
- X*
- X* ATX (613) 526-4141
- X* OMX (613) 731-3419
- X* Mystic (613) 731-0088 or (613) 731-6698
- X*
- X* Fidonet: 1:163/109.9
- X* Internet: David_Buck@Carleton.CA
- X*
- X*
- X*****************************************************************************/
- X
- X#include <stdio.h>
- X#include <exec/types.h>
- X#include "showprioq.h"
- X#include "dumptoiff.h"
- X#include "dumproto.h"
- X
- XULONG last_red = 0, last_green = 0, last_blue = 0;
- Xint Close_Threshold;
- X
- X#define absdif(x,y) ((x>y) ? (x-y):(y-x))
- X#define Make_Colour(x, y, z) ((x & 0xF) << 8) + ((y & 0xF) << 4) + (z & 0xF)
- X
- X#define extract_red(x) ((x & 0xF00) >> 8)
- X#define extract_green(x) ((x & 0x0F0) >> 4)
- X#define extract_blue(x) (x & 0x00F)
- X
- Xstruct prioq_struct *Colour_q;
- Xstruct prioq_struct *pq_new();
- X
- X
- Xextern UWORD ColourTbl[16];
- X
- Xvoid reset_colours ()
- X {
- X last_red = last_green = last_blue = 0;
- X }
- X
- Xint closeness(x, y)
- X int x, y;
- X {
- X int red, blue, green;
- X
- X red = absdif(extract_red(x), extract_red(y));
- X blue = absdif (extract_blue(x), extract_blue(y));
- X green = absdif(extract_green(x), extract_green(y));
- X return (red+blue+green);
- X }
- X
- Xvoid start_recording_colours ()
- X {
- X Colour_q = pq_new (256, 4096);
- X if (Colour_q == NULL)
- X exit (0);
- X
- X reset_colours();
- X }
- X
- Xvoid record_colours (new_red, new_green, new_blue)
- X int new_red, new_green, new_blue;
- X {
- X LONG delta_red, delta_green, delta_blue, match_quality;
- X
- X delta_red = absdif (new_red, last_red);
- X delta_green = absdif (new_green, last_green);
- X delta_blue = absdif (new_blue, last_blue);
- X
- X if (delta_red > delta_green)
- X if (delta_red > delta_blue) {
- X last_red = new_red;
- X match_quality = delta_green + delta_blue;
- X }
- X else {
- X last_blue = new_blue;
- X match_quality = delta_green + delta_red;
- X }
- X else
- X if (delta_green > delta_blue)
- X {
- X last_green = new_green;
- X match_quality = delta_red + delta_blue;
- X }
- X else {
- X last_blue = new_blue;
- X match_quality = delta_green + delta_red;
- X }
- X
- X if (match_quality != 0)
- X pq_add (Colour_q, match_quality,
- X Make_Colour (new_red, new_green, new_blue));
- X }
- X
- Xvoid choose_palette()
- X {
- X int i, j, colour, min_distance, temp_distance;
- X struct prioq_struct *post_pq;
- X
- X post_pq = pq_new (32, 4096);
- X
- X ColourTbl[0] = Make_Colour (0, 0, 0);
- X for (i=1 ; i < 16 ;) {
- X if (pq_get_highest_index (Colour_q) > pq_get_highest_index (post_pq))
- X {
- X colour = pq_get_highest_value (Colour_q);
- X pq_delete_highest (Colour_q);
- X
- X min_distance = 255;
- X for (j = 0 ; j < i ; j++)
- X if ((temp_distance = closeness (ColourTbl[j], colour)) < min_distance)
- X min_distance = temp_distance;
- X
- X if (min_distance < 5)
- X pq_add (post_pq, min_distance, colour);
- X else
- X ColourTbl[i++] = colour;
- X }
- X else
- X {
- X ColourTbl[i++] = pq_get_highest_value (post_pq);
- X pq_delete_highest (post_pq);
- X }
- X }
- X pq_free (Colour_q);
- X pq_free (post_pq);
- X }
- X
- Xint best_colour (new_red, new_blue, new_green)
- X int new_red, new_blue, new_green;
- X {
- X int i, match_quality, best_match, colour,
- X delta_red, delta_green, delta_blue, temp_match_quality;
- X
- X delta_red = absdif (new_red, last_red);
- X delta_green = absdif (new_green, last_green);
- X delta_blue = absdif (new_blue, last_blue);
- X
- X if (delta_red > delta_green)
- X if (delta_red > delta_blue) {
- X last_red = new_red;
- X colour = 0x20 + new_red;
- X match_quality = delta_green + delta_blue;
- X }
- X else {
- X last_blue = new_blue;
- X colour = 0x10 + new_blue;
- X match_quality = delta_green + delta_red;
- X }
- X else
- X if (delta_green > delta_blue)
- X {
- X last_green = new_green;
- X colour = 0x30 + new_green;
- X match_quality = delta_red + delta_blue;
- X }
- X else {
- X last_blue = new_blue;
- X colour = 0x10 + new_blue;
- X match_quality = delta_green + delta_red;
- X }
- X
- X if (match_quality != 0)
- X for (i = 0 ; i < 16 ; i++)
- X if ((temp_match_quality =
- X closeness (ColourTbl[i],
- X Make_Colour (new_red, new_green, new_blue)))
- X < match_quality) {
- X match_quality = temp_match_quality;
- X colour = i;
- X last_red = extract_red (ColourTbl[i]);
- X last_green = extract_green (ColourTbl[i]);
- X last_blue = extract_blue (ColourTbl[i]);
- X }
- X return (colour);
- X }
- X
- END_OF_FILE
- if test 5971 -ne `wc -c <'src/palette.c'`; then
- echo shar: \"'src/palette.c'\" unpacked with wrong size!
- fi
- # end of 'src/palette.c'
- fi
- if test -f 'src/prioq.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/prioq.c'\"
- else
- echo shar: Extracting \"'src/prioq.c'\" \(5064 characters\)
- sed "s/^X//" >'src/prioq.c' <<'END_OF_FILE'
- X/*****************************************************************************
- X*
- X* prioq.c
- X*
- X* from DKBTrace (c) 1990 David Buck
- X*
- X* This module implements a priority queue using a heap.
- X*
- X* This software is freely distributable. The source and/or object code may be
- X* copied or uploaded to communications services so long as this notice remains
- X* at the top of each file. If any changes are made to the program, you must
- X* clearly indicate in the documentation and in the programs startup message
- X* who it was who made the changes. The documentation should also describe what
- X* those changes were. This software may not be included in whole or in
- X* part into any commercial package without the express written consent of the
- X* author. It may, however, be included in other public domain or freely
- X* distributed software so long as the proper credit for the software is given.
- X*
- X* This software is provided as is without any guarantees or warranty. Although
- X* the author has attempted to find and correct any bugs in the software, he
- X* is not responsible for any damage caused by the use of the software. The
- X* author is under no obligation to provide service, corrections, or upgrades
- X* to this package.
- X*
- X* Despite all the legal stuff above, if you do find bugs, I would like to hear
- X* about them. Also, if you have any comments or questions, you may contact me
- X* at the following address:
- X*
- X* David Buck
- X* 22C Sonnet Cres.
- X* Nepean Ontario
- X* Canada, K2H 8W7
- X*
- X* I can also be reached on the following bulleton boards:
- X*
- X* ATX (613) 526-4141
- X* OMX (613) 731-3419
- X* Mystic (613) 731-0088 or (613) 731-6698
- X*
- X* Fidonet: 1:163/109.9
- X* Internet: David_Buck@Carleton.CA
- X*
- X* IBM Port by Aaron A. Collins. Aaron may be reached on the following BBS'es:
- X*
- X* Lattice BBS (708) 916-1200
- X* The Information Exchange BBS (708) 945-5575
- X* Stillwaters BBS (708) 403-2826
- X*
- X*****************************************************************************/
- X
- X#include "frame.h"
- X#include "dkbproto.h"
- X
- X#define NUMBER_OF_PRIOQS 20
- X#define NUMBER_OF_INTERSECTIONS 20
- X
- XPRIOQ *prioqs;
- X
- Xvoid pq_init ()
- X {
- X register int i;
- X PRIOQ *new_pq;
- X
- X prioqs = NULL;
- X
- X for (i = 0 ; i < NUMBER_OF_PRIOQS; i++)
- X {
- X if ((new_pq = (PRIOQ *) malloc (sizeof (PRIOQ))) == NULL) {
- X printf ("\nCannot allocate queues");
- X exit(1);
- X }
- X
- X new_pq -> next_pq = prioqs;
- X prioqs = new_pq;
- X
- X if ((new_pq -> queue = (INTERSECTION *)
- X malloc (128 * sizeof (INTERSECTION))) == NULL) {
- X printf ("\nCannot allocate queue entries");
- X exit(1);
- X }
- X }
- X }
- X
- XPRIOQ *pq_alloc()
- X {
- X PRIOQ *allocated_queue;
- X
- X if (prioqs == NULL) {
- X printf ("\nOut of prioqs");
- X exit(1);
- X }
- X
- X allocated_queue = prioqs;
- X prioqs = allocated_queue -> next_pq;
- X return (allocated_queue);
- X }
- X
- Xvoid pq_free (pq)
- X PRIOQ *pq;
- X {
- X pq -> next_pq = prioqs;
- X prioqs = pq;
- X }
- X
- XPRIOQ *pq_new (index_size)
- X int index_size;
- X {
- X PRIOQ *pq;
- X
- X if (index_size > 256)
- X return (NULL);
- X
- X if ((pq = pq_alloc()) == NULL)
- X return (NULL);
- X
- X pq -> queue_size = index_size;
- X pq -> current_entry = 0;
- X return (pq);
- X }
- X
- Xvoid pq_balance(q, entry_pos1)
- X PRIOQ *q;
- X unsigned int entry_pos1;
- X {
- X register INTERSECTION *entry1, *entry2;
- X INTERSECTION temp_entry;
- X register unsigned int entry_pos2;
- X
- X entry1 = &q->queue[entry_pos1];
- X
- X if ((entry_pos1 * 2 < q->queue_size)
- X && (entry_pos1 * 2 <= q -> current_entry))
- X {
- X if ((entry_pos1*2+1 > q->current_entry) ||
- X (q->queue[entry_pos1*2].Depth < q->queue[entry_pos1*2+1].Depth))
- X entry_pos2 = entry_pos1*2;
- X else
- X entry_pos2 = entry_pos1*2+1;
- X
- X entry2 = &q->queue[entry_pos2];
- X
- X if (entry1->Depth > entry2->Depth) {
- X temp_entry = *entry1;
- X *entry1 = *entry2;
- X *entry2 = temp_entry;
- X pq_balance (q, entry_pos2);
- X }
- X }
- X
- X if (entry_pos1 / 2 >= 1 )
- X {
- X entry_pos2 = entry_pos1 / 2;
- X entry2 = &q->queue[entry_pos2];
- X if (entry1->Depth < entry2->Depth) {
- X temp_entry = *entry1;
- X *entry1 = *entry2;
- X *entry2 = temp_entry;
- X pq_balance (q, entry_pos2);
- X }
- X }
- X }
- X
- Xvoid pq_add (q, entry)
- X PRIOQ *q;
- X INTERSECTION *entry;
- X {
- X q -> current_entry++;
- X if (q -> current_entry >= q -> queue_size)
- X q -> current_entry--;
- X
- X q -> queue [q -> current_entry] = *entry;
- X pq_balance (q, q -> current_entry);
- X }
- X
- XINTERSECTION *pq_get_highest(q)
- X PRIOQ *q;
- X {
- X if (q -> current_entry >= 1)
- X return (&(q -> queue[1]));
- X else
- X return (NULL);
- X }
- X
- Xint pq_is_empty(q)
- X PRIOQ *q;
- X {
- X if (q -> current_entry < 1)
- X return (TRUE);
- X else
- X return (FALSE);
- X }
- X
- Xvoid pq_delete_highest (q)
- X PRIOQ *q;
- X {
- X q -> queue[1] = q -> queue[q -> current_entry--];
- X pq_balance (q, 1);
- X }
- X
- END_OF_FILE
- if test 5064 -ne `wc -c <'src/prioq.c'`; then
- echo shar: \"'src/prioq.c'\" unpacked with wrong size!
- fi
- # end of 'src/prioq.c'
- fi
- if test -f 'src/raw.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/raw.c'\"
- else
- echo shar: Extracting \"'src/raw.c'\" \(4724 characters\)
- sed "s/^X//" >'src/raw.c' <<'END_OF_FILE'
- X/*****************************************************************************
- X*
- X* raw.c
- X*
- X* from DKBTrace (c) 1990 David Buck
- X*
- X* This file implements code to read in the raw 24 bit files produced by
- X* the raytracer to use as texture maps.
- X*
- X* This software is freely distributable. The source and/or object code may be
- X* copied or uploaded to communications services so long as this notice remains
- X* at the top of each file. If any changes are made to the program, you must
- X* clearly indicate in the documentation and in the programs startup message
- X* who it was who made the changes. The documentation should also describe what
- X* those changes were. This software may not be included in whole or in
- X* part into any commercial package without the express written consent of the
- X* author. It may, however, be included in other public domain or freely
- X* distributed software so long as the proper credit for the software is given.
- X*
- X* This software is provided as is without any guarantees or warranty. Although
- X* the author has attempted to find and correct any bugs in the software, he
- X* is not responsible for any damage caused by the use of the software. The
- X* author is under no obligation to provide service, corrections, or upgrades
- X* to this package.
- X*
- X* Despite all the legal stuff above, if you do find bugs, I would like to hear
- X* about them. Also, if you have any comments or questions, you may contact me
- X* at the following address:
- X*
- X* David Buck
- X* 22C Sonnet Cres.
- X* Nepean Ontario
- X* Canada, K2H 8W7
- X*
- X* I can also be reached on the following bulleton boards:
- X*
- X* ATX (613) 526-4141
- X* OMX (613) 731-3419
- X* Mystic (613) 731-0088 or (613) 731-6698
- X*
- X* Fidonet: 1:163/109.9
- X* Internet: David_Buck@Carleton.CA
- X*
- X* IBM Port by Aaron A. Collins. Aaron may be reached on the following BBS'es:
- X*
- X* Lattice BBS (708) 916-1200
- X* The Information Exchange BBS (708) 945-5575
- X* Stillwaters BBS (708) 403-2826
- X*
- X*****************************************************************************/
- X
- X
- X#include "frame.h"
- X#include "dkbproto.h"
- X
- Xint read_raw_byte(f)
- X FILE *f;
- X {
- X int c;
- X if ((c = getc(f)) == EOF)
- X return (-1);
- X return (c);
- X }
- X
- Xint read_raw_word(f)
- X FILE *f;
- X {
- X int byte1, byte2;
- X
- X byte1 = read_raw_byte(f);
- X if (byte1 == -1)
- X return(-1);
- X
- X byte2 = read_raw_byte(f);
- X if (byte2 == -1)
- X return(-1);
- X
- X return (byte1 + byte2*256);
- X }
- X
- Xvoid read_raw_image(Image, filename)
- X IMAGE *Image;
- X char *filename;
- X {
- X FILE *f;
- X int byte, i, index, row, pixels;
- X
- X if ((f = fopen(filename, "rb")) == NULL) {
- X printf ("Cannot open raw file %s\n", filename);
- X exit(1);
- X }
- X
- X Image->iwidth = read_raw_word(f);
- X if (Image->iwidth == -1) {
- X printf ("Cannot read size in dump file\n");
- X exit(1);
- X }
- X
- X Image->width = (DBL)Image->iwidth;
- X
- X Image->iheight = read_raw_word(f);
- X if (Image->iheight == -1) {
- X printf ("Cannot read size in dump file: %s\n", filename);
- X exit(1);
- X }
- X
- X Image->height = (DBL)Image->iheight;
- X
- X pixels = Image->iwidth * Image->iheight;
- X
- X if (((Image->red = (unsigned char *) malloc(pixels))==NULL) ||
- X ((Image->green = (unsigned char *) malloc(pixels))==NULL) ||
- X ((Image->blue = (unsigned char *) malloc(pixels))==NULL)) {
- X printf ("Cannot allocate memory for picture: %s\n", filename);
- X exit(1);
- X }
- X
- X for (i = 0 ; i < pixels ; i++) {
- X Image->red[i] = 0;
- X Image->green[i] = 0;
- X Image->blue[i] = 0;
- X }
- X
- X row = read_raw_word(f);
- X while (row != -1) {
- X for (i = 0 ; i < Image->iwidth ; i++) {
- X index = (Image->iheight-row)*Image->iwidth + i;
- X
- X byte = read_raw_byte(f);
- X if (byte == -1) {
- X printf ("Unexpected end of file in raw image: %s\n", filename);
- X exit(1);
- X }
- X Image->red[index] = byte;
- X }
- X
- X for (i = 0 ; i < Image->iwidth ; i++) {
- X index = (Image->iheight-row)*Image->iwidth + i;
- X byte = read_raw_byte(f);
- X if (byte == -1) {
- X printf ("Unexpected end of file in raw image: %s\n", filename);
- X exit(1);
- X }
- X Image->green[index] = byte;
- X }
- X
- X for (i = 0 ; i < Image->iwidth ; i++) {
- X index = (Image->iheight-row)*Image->iwidth + i;
- X byte = read_raw_byte(f);
- X if (byte == -1) {
- X printf ("Unexpected end of file in raw image: %s\n", filename);
- X exit(1);
- X }
- X Image->blue[index] = byte;
- X }
- X row = read_raw_word(f);
- X }
- X fclose (f);
- X }
- END_OF_FILE
- if test 4724 -ne `wc -c <'src/raw.c'`; then
- echo shar: \"'src/raw.c'\" unpacked with wrong size!
- fi
- # end of 'src/raw.c'
- fi
- if test -f 'src/showprioq.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'src/showprioq.c'\"
- else
- echo shar: Extracting \"'src/showprioq.c'\" \(5813 characters\)
- sed "s/^X//" >'src/showprioq.c' <<'END_OF_FILE'
- X/*****************************************************************************
- X*
- X* showprioq.c
- X*
- X* from DKBTrace (c) 1990 David Buck
- X*
- X* This file manages a priority queue for DumpToIFF
- X*
- X* This software is freely distributable. The source and/or object code may be
- X* copied or uploaded to communications services so long as this notice remains
- X* at the top of each file. If any changes are made to the program, you must
- X* clearly indicate in the documentation and in the programs startup message
- X* who it was who made the changes. The documentation should also describe what
- X* those changes were. This software may not be included in whole or in
- X* part into any commercial package without the express written consent of the
- X* author. It may, however, be included in other public domain or freely
- X* distributed software so long as the proper credit for the software is given.
- X*
- X* This software is provided as is without any guarantees or warranty. Although
- X* the author has attempted to find and correct any bugs in the software, he
- X* is not responsible for any damage caused by the use of the software. The
- X* author is under no obligation to provide service, corrections, or upgrades
- X* to this package.
- X*
- X* Despite all the legal stuff above, if you do find bugs, I would like to hear
- X* about them. Also, if you have any comments or questions, you may contact me
- X* at the following address:
- X*
- X* David Buck
- X* 22C Sonnet Cres.
- X* Nepean Ontario
- X* Canada, K2H 8W7
- X*
- X* I can also be reached on the following bulleton boards:
- X*
- X* ATX (613) 526-4141
- X* OMX (613) 731-3419
- X* Mystic (613) 731-0088 or (613) 731-6698
- X*
- X* Fidonet: 1:163/109.9
- X* Internet: David_Buck@Carleton.CA
- X*
- X*
- X*****************************************************************************/
- X
- X
- X#include <stdio.h>
- X#include <exec/types.h>
- X#include "showprioq.h"
- X#include "dumptoiff.h"
- X#include "dumproto.h"
- X
- Xchar *malloc();
- X
- X
- Xstruct prioq_struct *pq_new (index_size, value_size)
- X int index_size, value_size;
- X {
- X struct prioq_struct *pq;
- X unsigned char *tmp_array;
- X int i;
- X
- X if (index_size > 256)
- X return (NULL);
- X
- X if ((pq = (struct prioq_struct *) malloc
- X (sizeof (struct prioq_struct))) == NULL)
- X return (NULL);
- X
- X if ((pq -> queue = (struct q_entry *)
- X malloc (index_size * sizeof (struct q_entry))) == NULL) {
- X free (pq);
- X return (NULL);
- X }
- X
- X if ((pq -> array = (unsigned char *) malloc (value_size)) == NULL) {
- X free (pq -> queue);
- X free (pq);
- X return (NULL);
- X }
- X
- X for (i=0, tmp_array = pq -> array ; i<value_size ; i++, tmp_array++)
- X *tmp_array = 0;
- X
- X pq -> queue_size = index_size;
- X pq -> array_size = value_size;
- X pq -> current_entry = 0;
- X return (pq);
- X }
- X
- Xvoid pq_add (q, index, value)
- X struct prioq_struct *q;
- X unsigned int index, value;
- X {
- X unsigned int existing_entry;
- X
- X if (value >= q -> array_size)
- X return;
- X
- X if ((existing_entry = pq_find_value(q, value)) != 0) {
- X if ((q -> queue[existing_entry].index) < index)
- X (q -> queue[existing_entry].index) = index;
- X pq_balance (q, existing_entry);
- X }
- X else {
- X q -> current_entry++;
- X if (q -> current_entry >= q -> queue_size) {
- X q -> current_entry--;
- X q -> array [q->queue[q->current_entry].value] = 0;
- X }
- X
- X q -> queue [q -> current_entry].index = index;
- X q -> queue [q -> current_entry].value = value;
- X q -> array [value] = q -> current_entry;
- X pq_balance (q, q -> current_entry);
- X }
- X return;
- X }
- X
- Xint pq_find_value (q, value)
- X struct prioq_struct *q;
- X unsigned int value;
- X {
- X if (value < q -> array_size)
- X return ((int) q -> array[value]);
- X else
- X return (0);
- X }
- X
- Xvoid pq_balance(q, entry_pos1)
- X struct prioq_struct *q;
- X unsigned int entry_pos1;
- X {
- X register struct q_entry *entry1, *entry2;
- X register unsigned int tmp_index, tmp_value, entry_pos2;
- X
- X entry1 = &q->queue[entry_pos1];
- X
- X if ((entry_pos1 * 2 < q->queue_size)
- X && (entry_pos1 * 2 <= q -> current_entry))
- X {
- X if ((entry_pos1*2+1 > q->current_entry) ||
- X (q->queue[entry_pos1*2].index > q->queue[entry_pos1*2+1].index))
- X entry_pos2 = entry_pos1*2;
- X else
- X entry_pos2 = entry_pos1*2+1;
- X
- X entry2 = &q->queue[entry_pos2];
- X
- X if (entry1->index < entry2->index) {
- X q -> array [entry1->value] = entry_pos2;
- X q -> array [entry2->value] = entry_pos1;
- X
- X tmp_index = entry1->index;
- X entry1->index = entry2->index;
- X entry2->index = tmp_index;
- X
- X tmp_value = entry1->value;
- X entry1->value = entry2->value;
- X entry2->value = tmp_value;
- X
- X pq_balance (q, entry_pos2);
- X }
- X }
- X
- X if (entry_pos1 / 2 >= 1 )
- X {
- X entry_pos2 = entry_pos1 / 2;
- X entry2 = &q->queue[entry_pos2];
- X if (entry1->index > entry2->index) {
- X q -> array [entry1->value] = entry_pos2;
- X q -> array [entry2->value] = entry_pos1;
- X
- X tmp_index = entry1->index;
- X entry1->index = entry2->index;
- X entry2->index = tmp_index;
- X
- X tmp_value = entry1->value;
- X entry1->value = entry2->value;
- X entry2->value = tmp_value;
- X
- X pq_balance (q, entry_pos2);
- X }
- X }
- X }
- X
- Xint pq_get_highest_index(q)
- X struct prioq_struct *q;
- X {
- X if (q -> current_entry >= 1)
- X return ((int) q -> queue[1].index);
- X else
- X return (0);
- X }
- X
- Xint pq_get_highest_value(q)
- X struct prioq_struct *q;
- X {
- X if (q -> current_entry >= 1)
- X return ((int) q -> queue[1].value);
- X else
- X return (0);
- X }
- X
- Xvoid pq_delete_highest (q)
- X struct prioq_struct *q;
- X {
- X q -> queue[1].index = q -> queue[q -> current_entry].index;
- X q -> queue[1].value = q -> queue[q -> current_entry--].value;
- X pq_balance (q, 1);
- X }
- X
- Xvoid pq_free (q)
- X struct prioq_struct *q;
- X {
- X free (q ->queue);
- X free (q -> array);
- X free (q);
- X }
- END_OF_FILE
- if test 5813 -ne `wc -c <'src/showprioq.c'`; then
- echo shar: \"'src/showprioq.c'\" unpacked with wrong size!
- fi
- # end of 'src/showprioq.c'
- fi
- echo shar: End of archive 2 \(of 10\).
- cp /dev/null ark2isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 10 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
- Mail comments to the moderator at <amiga-request@uunet.uu.net>.
- Post requests for sources, and general discussion to comp.sys.amiga.
-